<?
/* $Id: init.php 52 2011-02-21 13:35:10Z jim2212001@gmail.com $ */
session_start();
$path = WEBHOME . '/libs';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once('mysqlidb.class.php');
require_once('Smarty.class.php');
require_once('SaltMd5.class.php');
require_once('perm.php');
require_once('msg.php');
require_once('str.php');
$tpl = new Smarty();
$tpl->template_dir = WEBHOME . '/templates/';
$tpl->compile_dir = WEBHOME . '/templates_c/';
$tpl->config_dir = WEBHOME . '/configs/';
$tpl->cache_dir = WEBHOME . '/cache/';
$tpl->left_delimiter = '<{';
$tpl->right_delimiter = '}>';
$tpl->assign('title',TITLE);
$info = pathinfo($_SERVER['SCRIPT_NAME']);
$tpl->assign('_page',basename($_SERVER['SCRIPT_NAME'],'.'.$info['extension']));
$tpl->assignByRef('_errorMsg',$_errorMsg);
$tpl->assignByRef('_infoMsg',$_infoMsg);

$db = new mysqlidb(DB_HOST,DB_USER,DB_PW,DB_DB);
/* check connection */
if (mysqli_connect_error()) {
    printf("Connect failed");
	debugMsg('(%d): %s\n',mysqli_connect_errno(),mysqli_connect_error());
    exit();
}
$db->query('SET NAMES \'utf8\'');
/* init message */
if(isset($_SESSION['_msg'])){
	foreach($_SESSION['_msg'] as $msg){
		if($msg['type']=='error')
			errMsg($msg['reason']);
		elseif($msg['type']=='info')
			infoMsg($msg['reason']);
	}
	unset($_SESSION['_msg']);
}
mb_internal_encoding('UTF-8');
?>
